﻿<Page x:Class="MenuGridFinal.RunningGame"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:MenuGridFinal"
      mc:Ignorable="d" 
      Title="RunningGame">
    <Grid x:Name="theGame" Focusable="True" KeyDown="Grid_KeyDown" Loaded="theGame_Loaded">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="245"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <!-- Panel_Begin -->
        
        <!-- Map, 0.row -->
        <Image Source="Images/InGame_Map.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Grid.RowSpan="1"/>

        <!-- Gold, 1.row -->
        <Image Source="Images/InGame_Gold.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="1"/>
        <TextBlock Text="{Binding Panel.Gold}" Style="{StaticResource heavyText}" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" />
        
        <!-- Food, 2.row -->
        <Image Source="Images/InGame_Food.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Grid.RowSpan="1"/>
        <TextBlock Text="{Binding Panel.Food}" Style="{StaticResource heavyText}" Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1"/>
        
        <!-- Wood, 3.row -->
        <Image Source="Images/InGame_Wood.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3" Grid.RowSpan="1"/>
        <TextBlock Text="{Binding Panel.Wood}" Style="{StaticResource heavyText}" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1"/>

        <!-- Unit//Image and Name, 4-5.row -->
        <Image Source="Images/InGame_Unit.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="4" Grid.RowSpan="2"/>
        <Image Source="{Binding Panel.SelectedMapObjectImage, Converter={StaticResource MapObjectImageConverter}}" Stretch="Uniform" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="4" Grid.RowSpan="1"/>
        <TextBlock Text="{Binding Panel.SelectedMapObjectLabel}" Style="{StaticResource heavyText}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="5" Grid.RowSpan="1"/>

        <!-- Infos from unit, 6-7.row -->
        <Image Source="Images/InGame_SelectedInfo.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="6" Grid.RowSpan="2"/>
        <TextBlock Text="{Binding Panel.SelectedMapObjectHealth}" Style="{StaticResource lightText}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="6" Grid.RowSpan="1"/>
        <TextBlock Text="{Binding Panel.SelectedMapObjectInfo}" Style="{StaticResource lightText}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="7" Grid.RowSpan="1"/>

        <!-- Unit Action, 8-11.row -->
        <Image Source="Images/InGame_Action.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="8" Grid.RowSpan="2"/>
        <Image Source="Images/InGame_Action.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="9" Grid.RowSpan="2"/>
        <Image Source="Images/InGame_Action.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="10" Grid.RowSpan="2"/>
        <Image Source="Images/InGame_Action.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="11" Grid.RowSpan="2"/>
        <Grid Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="8" Grid.RowSpan="4">
            <ItemsControl ItemsSource="{Binding Panel.Actions}">
                <ItemsControl.Resources>

                    <DataTemplate DataType="{x:Type local:ActionOnPanel}">
                        <Button x:Name="Action"
                                BorderThickness="0"  
                                Width="100"
                                Height="100"
                                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
                            <Button.InputBindings>
                                <MouseBinding Gesture="LeftClick" Command="{Binding DataContext.ActionClickCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
                                <MouseBinding Gesture="RightClick" Command="{Binding DataContext.ActionClickCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
                            </Button.InputBindings>
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <Grid>
                                        <Image Source="{Binding Type, Converter={StaticResource ActionImageConverter}}" Stretch="Fill"/>
                                        <TextBlock Text="{Binding Label}" Style="{StaticResource lightText}" Grid.Row="1"/>
                                    </Grid>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>

                    </DataTemplate>
                </ItemsControl.Resources>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel></WrapPanel>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Grid>
        
        <!-- EpicPicture, 12.row -->
        <Image Source="Images/InGame_Image.png" Stretch="Fill" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="12" Grid.RowSpan="1"/>

        <!-- MainMenuButton, 13.row -->
        <Button Name="MainMenuButton" Content="MainMenu" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="13" Click="MainMenuButton_Click"/>

        <!-- Panel_End -->    
              
        <!-- MapGrid_Begin, 0.Column, 0.Row -->
        <Grid Grid.Row="0" Grid.RowSpan="14" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">

            <ItemsControl ItemsSource="{Binding Tiles}">
                <ItemsControl.Resources>

                    <DataTemplate DataType="{x:Type local:Tile}">
                        <Button x:Name="Tile"
                                BorderThickness="0"  
                                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
                            <Button.InputBindings>
                                <MouseBinding Gesture="LeftClick" Command="{Binding DataContext.TileRightClickCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
                                <MouseBinding Gesture="RightClick" Command="{Binding DataContext.TileClickCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
                            </Button.InputBindings>
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <Grid>
                                        <Image Source="{Binding StoredFieldImage, Converter={StaticResource FieldImageConverter}}" Stretch="Fill" />
                                        <Image Source="{Binding StoredMapObjectImage, Converter={StaticResource MapObjectImageConverter}}" Stretch="Fill" />
                                        <Image Source="{Binding StoredBulletImage, Converter={StaticResource MapObjectImageConverter}}" Stretch="Fill" />
                                        <Image Source="{Binding AllowBuild, Converter={StaticResource AllowBuildImageConverter}}" Stretch="Fill" />
                                        <Image Source="{Binding Visibility, Converter={StaticResource VisibilityImageConverter}}" Stretch="Fill" />
                                        <Image Source="{Binding Selection, Converter={StaticResource SelectionImageConverter}}" Stretch="Fill" />
                                    </Grid>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>

                    </DataTemplate>
                </ItemsControl.Resources>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid Rows="{Binding Rows}" Columns="{Binding Columns}"></UniformGrid>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Grid>
        <Image Source="{Binding Panel.CurrentGameState, Converter={StaticResource GameStateConverter}}" Stretch="Fill" Grid.RowSpan="10" Grid.Row="2"></Image>

        <!-- MapGrid_End -->
        
        <!-- Chat_Begin 0.Column, x.Row-->
        <!--
        <StackPanel Background="Green" Grid.Row="11" HorizontalAlignment="Left" Width="450">
            <TextBox x:Name="textBoxChatPane" Focusable = "False" Margin="20" Height="150"  HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Width="400" Visibility="Visible"/>
            <TextBox x:Name="textBoxEntryField"  Height="25" VerticalAlignment="Bottom" Margin="20,20" TextWrapping="Wrap" Width="400" KeyDown="textBoxEntryField_KeyDown" TextChanged="textBoxEntryField_TextChanged"/>
        </StackPanel>
        -->
        <!-- Chat_end -->
    
   </Grid>
</Page>
